package com.wx.mall.operate.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wx.mall.common.api.CommonResult;
import com.wx.mall.operate.dto.DisClassDto;
import com.wx.mall.operate.entity.DisClass;
import com.wx.mall.operate.entity.Discount;
import com.wx.mall.operate.service.IDisClassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 优惠券分类表关联 前端控制器
 * </p>
 *
 * @author j
 * @since 2020-05-27
 */
@RestController
@RequestMapping("/dis-class")
@Api(tags = "优惠分类表")
public class DisClassController {

    @Resource
    private IDisClassService service;

    @ApiOperation("清空数据根据优惠券id")
    @DeleteMapping("/deleteByDisId")
    public CommonResult deleteByDisId(Integer disId){

        QueryWrapper<DisClass> wrapper=new QueryWrapper<>();
        wrapper.eq("dis_id",disId);
        boolean suceess=service.remove(wrapper);

        return suceess?CommonResult.success():CommonResult.failed();
    }


    @ApiOperation("添加数据")
    @PostMapping("/addList")
    public CommonResult addOne(DisClassDto dto){
        System.out.println(dto);
        service.addOne(dto);
        return CommonResult.success();
    }



}

